import React, { Component } from 'react';
import ReactSwiper from 'reactjs-swiper';
import '../../static/css/swiper.css'
import axios from 'axios'

const swiperOptions = {
  slidesPerView: 5,
  spaceBetween: 0,
  //autoplay: 1000,
  autoplayDisableOnInteraction: false
};
class Swiper extends Component {

  constructor(props){
    super(props);
    this.state = {
      items:[],
    };
  }
  componentWillMount(){
    var items = [];
    let that = this;
    axios.get('http://80days.lockinchina.com/apib/eightyDay/recommendedCompanyList').then(function (res){
      const data = res.data;
      if(data.code === 200){
        const content = data.data
        if(content){
          content.map((item,index) => {
            return items.push({
              image: item.imageUrl, 
              link: 'http://job.lockinchina.com/company/companyDetail?companyId='+item.companyId
            })
          })
        }
        that.setState({
          items:items
        })
      }
    })
  }
  render () {
    return (
      <div className="swiper-box">
        <h3 className="title">推荐企业</h3>
        <ReactSwiper 
          showPagination={false}
          options={swiperOptions}
          items={this.state.items}
          className="swiper-example"
        />
      </div>
    )
  }
}
export default Swiper